home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
5_5.lha
/
5_5
/
5_5a.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
666b
|
43 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <5.5A.h>
tatic void treeprint(tree* head)
if (head)
switch (head->type)
{
case PLUS: case MINUS: case DIV: case MULT:
cout << "(";
treeprint(head->left);
cout << chr(head->type);
treeprint(head->right);
cout << ")";
break;
case NEG:
cout << "-(";
treeprint(head->left);
cout << ")";
break;
case NUMBER:
cout << head->value;
break;
default:
error("unknown type within tree");
break;
}
else
error("null node found");
oid expr:: print()
treeprint(head);